<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends CommonController {
    public function login(){
		
        $this->display();
    }
    //登录添加查询接口
    public function check(){
		$account = I('post.account');
		$password = I('post.password');
		
		if( $account == '' || $password == ''){
			$this->response( false , 2 , '账号跟密码不能为空' , true);
		}
		
		$Account	= M('Account');
		$password	= md5($password);
		
		//查询接口
		$res = $Account->where("account='{$account}' and password='{$password}'")->find();
		
		if( $res == false){
			$this->response( false , 1 , '账号或者密码错误' , true);
		}

		$_SESSION['UID']		= $res['id'];
		$_SESSION['ACCOUNT']	= $res['account'];
		
		$this->response( true , 0 , '登录成功' ,true);

	}
	
	public function loginout(){
		$_SESSION['UID']		= '';
		$_SESSION['ACCOUNT']	= '';
		$this->redirect('Admin/login/login');
	}
}
